package com.group.nepm.publicSuperviseDataManagement.controller;

import com.group.common.utils.MyUtils;
import com.group.neps.entity.RowAqiData;
import com.group.neps.entity.RowAqiLevel;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;

public class ThePublic_DetialController {

    //设置静态变量以获取数据
    private static RowAqiData selectedRowAqiData;
    private static int selectId;

    public static void NEPMsetSelectedRowAqiData(RowAqiData data,int id) {
        selectedRowAqiData = data;
        selectId = id;
    }

    public static RowAqiData NEPMgetSelectedRowAqiData() {
        return selectedRowAqiData;
    }


    @FXML
    private Label NEPSId;
    @FXML
    private Label NEPSMessage;
    @FXML
    private Label NEPSPhoneNumber;
    @FXML
    private Label NEPSLocation;
    @FXML
    private Label NEPSDescribe;
    @FXML
    private Label NEPSLevel;
    @FXML
    private Label NEPSTime;

    private String id;
    private String message;
    private String phoneNumber;
    private String location;
    private String describe;
    private String level;
    private String time;

    public void adminOut(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/common/view/NEPMLoginView.fxml");
    }
    public void toPublicSuperviseDataList(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/publicSuperviseDataManagement/view/PublicSuperviseDataList.fxml");
    }
    public void toConfirmAqiDataList(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/publicSuperviseDataManagement/view/ConfirmAqiDataList.fxml");
    }
    public void toProvinceStatistic(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/statisticDataManagement/view/provinceStatistic.fxml");
    }
    public void toAqiDistributionStatistic(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/statisticDataManagement/view/aqiDistributionStatistic.fxml");
    }
    public void toAqiTendencyStatistic(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/statisticDataManagement/view/aqiTendencyStatistic.fxml");
    }
    public void toOtherDataStatistic(ActionEvent event) {
        MyUtils.navigateToView(event, "group/nepm/statisticDataManagement/view/otherDataStatistic.fxml");
    }


    //显示表中内容
    public void initialize() {
        int id = selectId;
        String message = selectedRowAqiData.getUser().getUsername() +" " + selectedRowAqiData.getUser().getSex();
        String phoneNumber = selectedRowAqiData.getUser().getPhoneNumber();
        String location = selectedRowAqiData.getLocation().getProvince().getName() +" " + selectedRowAqiData.getLocation().getCity().getName() + " " + selectedRowAqiData.getLocation().getAddress();
        RowAqiLevel level = selectedRowAqiData.getAqiLevel();
        int key = level.ordinal()+1;
        String AQILevel = "";
        String describe = "";
        switch (key){
            case 1:{
                AQILevel = "一级 优";
                describe = "空气质量令人满意，基本无空气污染";
                break;
            }
            case 2:{
                AQILevel = "二级 良";
                describe = "空气质量可接受，但某些污染物可能对极少数异常敏感人群健康有较弱影响";
                break;
            }
            case 3:{
                AQILevel = "三级 轻度污染";
                describe = "易感人群症状有轻度加剧，健康人群出现刺激症状";
                break;
            }
            case 4:{
                AQILevel = "四级 中度污染";
                describe = "进一步加剧易感人群症状，可能对健康人群心脏、呼吸系统有影响";
                break;
            }
            case 5:{
                AQILevel = "五级 重度污染";
                describe = "心脏病和肺病患者症状显著加剧，运动耐受力降低，健康人群普遍出现症状";
                break;
            }
            case 6:{
                AQILevel = "六级 严重污染";
                describe = "健康人群运动耐受力降低，有明显强烈症状，提前出现某些疾病";
                break;
            }

        }
        NEPSLevel.setText(AQILevel);
        NEPSId.setText(String.format("%d", id));
        NEPSMessage.setText(message);
        NEPSPhoneNumber.setText(phoneNumber);
        NEPSLocation.setText(location);
        NEPSDescribe.setText(describe);
        NEPSLevel.setText(AQILevel);
        String time = selectedRowAqiData.getTime().toString();
        NEPSTime.setText(time);
        //TODO
    }

    //返回
    public void back(ActionEvent actionEvent) {
        MyUtils.navigateToView(actionEvent, "group/nepm/publicSuperviseDataManagement/view/PublicSuperviseDataList.fxml");
    }
}
